package org.meb.speedway.model.event;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Version;

import lombok.Getter;
import lombok.Setter;

import org.hibernate.annotations.ForeignKey;
import org.meb.speedway.model.event.Heat.Gate;
import org.meb.speedway.model.registry.Rider;

@Entity
@Table(name = "t_heat_comp")
@Getter
@Setter
public class HeatComp implements Serializable {

	private static final long serialVersionUID = 9156187488155373386L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;

	@Version
	private Long version;

	@ManyToOne
	@JoinColumn(name = "heat_id")
	@ForeignKey(name = "HECO_HEAT_FK")
	private Heat heat;

	@ManyToOne
	@JoinColumn(name = "rider_id")
	@ForeignKey(name = "HECO_RIDR_FK")
	private Rider rider;

	@Column(name = "rider_status", nullable = false, length = 20)
	@Enumerated(EnumType.STRING)
	private HeatRiderStatus riderStatus;

	@ManyToOne
	@JoinColumn(name = "sub_rider_id")
	@ForeignKey(name = "HECO_SRDR_FK")
	private Rider subRider;

	@Basic
	@Column(name = "sub_rider_status")
	@Enumerated(EnumType.STRING)
	private HeatRiderStatus subRiderStatus;

	@Column(name = "sub_type", length = 20)
	@Enumerated(EnumType.STRING)
	private SubType subType;

	@Basic(optional = false)
	@Enumerated(EnumType.STRING)
	private Gate gate;

	@Basic
	private Integer place;

	@Basic
	private Integer points;
}
